﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using QuanLyDuocPham.Controllers.QuanLyHeThong.DanhMuc;
using QuanLyDuocPham.Controllers.UC.QuanLyHeThong.DanhMuc;

namespace QuanLyDuocPham.View.QuanLyHeThong.DanhMuc
{
    /// <summary>
    /// Interaction logic for VATTU_Add_View.xaml
    /// </summary>
    public partial class VATTU_Add_View : Window
    {
        public VATTU_Add_View()
        {
            InitializeComponent();
        }
        public delegate void added();
        public added done;
        
        DUOCPHAM_Control dpctrl = new DUOCPHAM_Control();
        NHOMDP_Control ndpctrl = new NHOMDP_Control();
        DONVITINH_Control dvtctrl = new DONVITINH_Control();
        NCC_Control nccctrl = new NCC_Control();
        NSX_Control nsxctrl = new NSX_Control();
        THUESUAT_Control thuectrl = new THUESUAT_Control();
        string ma_dp;
        public string _ma_dp
        {
            set
            {
                ma_dp = value;
            }
        }
        UIElement ui;
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ma_dp = dpctrl.loadID_moi();
            ndpctrl.loadComboBox(cmbNhom_VT);
            cmbNhom_VT.SelectedIndex = 0;
            dvtctrl.loadComboBox(cmbDVT);
            cmbDVT.SelectedIndex = 0;
            nccctrl.loadComboBox(cmbNCC);
            cmbNCC.SelectedIndex = 0;
            nsxctrl.loadComboBox(cmbNSX);
            cmbNSX.SelectedIndex = 0;
            thuectrl.loadComboBox(cmbThue);
            cmbThue.SelectedIndex = 0;
            
            UC_HOATCHAT_ListCheck ul = new UC_HOATCHAT_ListCheck();
            ul.Margin = new Thickness(10, 76, 0, 0);
            MainFrame.Children.Add(ul);
            ui = ul;
            
        }

        private void btBack_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
        GIA_Control giactrl = new GIA_Control();
        private void btOk_Click(object sender, RoutedEventArgs e)
        {
            dpctrl.addData(ma_dp, cmbDVT, cmbNhom_VT, cmbThue, cmbNSX, cmbNCC, txtTen_Biet_Duoc, txtTon_NN, txtTon_LN, txtPhan_Loai, chbDoc_Duoc, txtHDSD, txtHanDung, txtDong_Goi, txtNong_Do, txtSDK, txtNhietDo_BaoQuan, chbASMT, chbAm, chbDong, chbNong, txtCong_Dung, txtGhi_Chu, txtTem);
            ma_dp = dpctrl.loadID_moi();

            
            cmbDVT.SelectedItem = null;
            cmbNCC.SelectedItem = null;
            cmbNhom_VT.SelectedItem = null;
            cmbNSX.SelectedItem = null;
            cmbThue.SelectedItem = null;
            
            txtCong_Dung.Clear();
            txtDong_Goi.Clear();
            txtGhi_Chu.Clear();
            txtHanDung.Clear();
            txtHDSD.Clear();
            txtNhietDo_BaoQuan.Clear();
            txtNong_Do.Clear();
            txtPhan_Loai.Clear();
            txtSDK.Clear();
            txtTem.Clear();
            txtTen_Biet_Duoc.Clear();
            txtTon_LN.Clear();
            txtTon_NN.Clear();
            chbAm.IsChecked = false;
            chbASMT.IsChecked = false;
            chbDoc_Duoc.IsChecked = false;
            chbDong.IsChecked = false;
            chbNong.IsChecked = false;
            giactrl.addData(ma_dp, txtGia_Si, txtGia_Le);


        }
    }
}
